# Generated manually to update existing random match records to realtime

from django.db import migrations

def update_random_to_realtime(apps, schema_editor):
    """将现有的'random'匹配记录更新为'realtime'"""
    MatchQueue = apps.get_model('battles', 'MatchQueue')
    MatchQueue.objects.filter(match_mode='random').update(match_mode='realtime')

def reverse_realtime_to_random(apps, schema_editor):
    """回滚操作：将'realtime'记录改回'random'"""
    MatchQueue = apps.get_model('battles', 'MatchQueue')
    MatchQueue.objects.filter(match_mode='realtime').update(match_mode='random')

class Migration(migrations.Migration):

    dependencies = [
        ('battles', '0013_update_match_modes'),
    ]

    operations = [
        migrations.RunPython(
            update_random_to_realtime,
            reverse_realtime_to_random,
        ),
    ]